/*
 * @Description: 
 * @Author: fhw
 * @Date: 2022-11-28 11:38:16
 */
import { ApiProperty } from "@nestjs/swagger";
import { ChatUser } from "src/chat_user/entities/chat_user.entity";
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
@Entity('resume')
export class Resume {
    @ApiProperty({ example: 'id', description: 'id' })
    @PrimaryGeneratedColumn({
        type: 'int',
        comment: 'id',
    })
    id: number

    @ApiProperty({ example: 'name', description: '用户名' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '用户名',
    })
    name: string

    @ApiProperty({ example: 'sex', description: '性别' })
    @Column({
        comment: '性别',
        type: 'enum',
        enum: ['男', '女', '未知'],
    })
    sex: string

    @ApiProperty({ example: 'nativePlace', description: '籍贯' })
    @Column({
        type: 'varchar',
        comment: '籍贯',
    })
    nativePlace: string

    @ApiProperty({ example: 'mail', description: '邮箱' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '邮箱',
    })
    mail: string

    @ApiProperty({ example: 'education', description: '学历' })
    @Column({
        type: 'varchar',
        length: 10,
        comment: '学历',
    })
    education: string

    @ApiProperty({ example: 'phone', description: '电话' })
    @Column({
        type: 'varchar',
        length: 12,
        comment: '电话',
    })
    phone: string

    @ApiProperty({ example: 'experience', description: '工作经验' })
    @Column({
        type: 'varchar',
        length: 10,
        comment: '工作经验',
    })
    experience: string

    @ApiProperty({ example: 'occupation', description: '职业' })
    @Column({
        type: 'varchar',
        length: 20,
        comment: '职业',
    })
    occupation: string

    @ApiProperty({ example: 'userImage', description: '头像地址' })
    @Column({
        type: 'text',
        comment: '头像地址',
    })
    userImage: string

    @ApiProperty({ example: 'PDFUrl', description: 'PDF下载地址' })
    @Column({
        type: 'varchar',
        length: 255,
        comment: 'PDF下载地址',
    })
    PDFUrl: string

    @ApiProperty({ example: 'createDate', description: '创建时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '创建时间',
    })
    createDate: string

    @ApiProperty({ example: 'updateDate', description: '更新时间' })
    @UpdateDateColumn({
        type: 'datetime',
        comment: '更新时间',
    })
    updateDate: string;

    @ApiProperty({ example: 'userId', description: '聊天用户id' })
    @Column({
        type: 'int',
        comment: '聊天用户id',
    })
    userId: number;

    // 绑定用户
    @OneToOne(() => ChatUser, (user) => user.id)
    @JoinColumn({ name: 'userId' })
    user: ChatUser;

    // 教育经历
    @OneToMany(() => ResumeEducation, (resumeEducation) => resumeEducation.resume)
    resumeEducation: ResumeEducation[];

    // 工作经历
    @OneToMany(() => ResumeExperience, (resumeExperience) => resumeExperience.resume)
    resumeExperience: ResumeExperience[];

    // 项目经验
    @OneToMany(() => ResumeProject, (resumeProject) => resumeProject.resume)
    resumeProject: ResumeProject[];
    // 技术
    @OneToMany(() => ResumeSkill, (resumeSkill) => resumeSkill.resume)
    resumeSkill: ResumeSkill[];
    // 技术描述
    @OneToMany(() => ResumeSkilltxt, (resumeSkilltxt) => resumeSkilltxt.resume)
    resumeSkilltxt: ResumeExperience[];


}
// 教育经历
@Entity('resume_education')
export class ResumeEducation {
    @ApiProperty({ example: 'id', description: 'id' })
    @PrimaryGeneratedColumn({
        type: 'int',
        comment: 'id',
    })
    id: number

    @ApiProperty({ example: 'title', description: '标题' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '标题',
    })
    title: string

    @ApiProperty({ example: 'major', description: '专业' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '专业',
    })
    major: string

    @ApiProperty({ example: 'date', description: '时间' })
    @Column({
        type: 'varchar',
        length: 25,
        comment: '时间',
    })
    date: string

    @ApiProperty({ example: 'date', description: '创建时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '创建时间',
    })
    createDate: string;

    @ApiProperty({ example: 'updateDate', description: '更新时间' })
    @UpdateDateColumn({
        type: 'datetime',
        comment: '更新时间',
    })
    updateDate: string;

    // 绑定简历主表
    @ApiProperty({ example: 'resumeId', description: '简历ID' })
    @Column({
        type: 'int',
        comment: '简历ID',
    })
    resumeId: number;
    @ManyToOne(() => Resume, (resume) => resume.id)
    @JoinColumn({ name: 'resumeId' })
    resume: Resume;
}

// 工作经历
@Entity('resume_experience')
export class ResumeExperience {
    @ApiProperty({ example: 'id', description: 'id' })
    @PrimaryGeneratedColumn({
        type: 'int',
        comment: 'id',
    })
    id: number

    @ApiProperty({ example: 'title', description: '标题' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '标题',
    })
    title: string

    @ApiProperty({ example: 'text', description: '内容' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '内容',
    })
    text: string

    @ApiProperty({ example: 'date', description: '时间' })
    @Column({
        type: 'varchar',
        length: 25,
        comment: '时间',
    })
    date: string

    @ApiProperty({ example: 'date', description: '创建时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '创建时间',
    })
    createDate: string;

    @ApiProperty({ example: 'updateDate', description: '更新时间' })
    @UpdateDateColumn({
        type: 'datetime',
        comment: '更新时间',
    })
    updateDate: string;

    // 绑定简历主表
    @ApiProperty({ example: 'resumeId', description: '简历ID' })
    @Column({
        type: 'int',
        comment: '简历ID',
    })
    resumeId: number;
    @ManyToOne(() => Resume, (resume) => resume.id)
    @JoinColumn({ name: 'resumeId' })
    resume: Resume;
}

// 项目经验
@Entity('resume_project')
export class ResumeProject {
    @ApiProperty({ example: 'id', description: 'id' })
    @PrimaryGeneratedColumn({
        type: 'int',
        comment: 'id',
    })
    id: number

    @ApiProperty({ example: 'title', description: '标题' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '标题',
    })
    title: string

    @ApiProperty({ example: 'describe', description: '项目内容描述' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '项目内容描述',
    })
    describe: string

    @ApiProperty({ example: 'technology', description: '使用技术' })
    @Column({
        type: 'text',
        comment: '使用技术',
    })
    technology: string

    @ApiProperty({ example: 'date', description: '创建时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '创建时间',
    })
    createDate: string;

    @ApiProperty({ example: 'updateDate', description: '更新时间' })
    @UpdateDateColumn({
        type: 'datetime',
        comment: '更新时间',
    })
    updateDate: string;

    // 绑定简历主表
    @ApiProperty({ example: 'resumeId', description: '简历ID' })
    @Column({
        type: 'int',
        comment: '简历ID',
    })
    resumeId: number;
    @ManyToOne(() => Resume, (resume) => resume.id)
    @JoinColumn({ name: 'resumeId' })
    resume: Resume;
}

// 技术
@Entity('resume_skill')
export class ResumeSkill {
    @ApiProperty({ example: 'id', description: 'id' })
    @PrimaryGeneratedColumn({
        type: 'int',
        comment: 'id',
    })
    id: number

    @ApiProperty({ example: 'title', description: '标题' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '标题',
    })
    title: string

    @ApiProperty({ example: 'count', description: '掌握程度' })
    @Column({
        type: 'tinyint',
        comment: '掌握程度',
    })
    count: number

    @ApiProperty({ example: 'date', description: '创建时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '创建时间',
    })
    createDate: string;

    @ApiProperty({ example: 'updateDate', description: '更新时间' })
    @UpdateDateColumn({
        type: 'datetime',
        comment: '更新时间',
    })
    updateDate: string;

    // 绑定简历主表
    @ApiProperty({ example: 'resumeId', description: '简历ID' })
    @Column({
        type: 'int',
        comment: '简历ID',
    })
    resumeId: number;
    @ManyToOne(() => Resume, (resume) => resume.id)
    @JoinColumn({ name: 'resumeId' })
    resume: Resume;
}

// 技术描述
@Entity('resume_skilltxt')
export class ResumeSkilltxt {
    @ApiProperty({ example: 'id', description: 'id' })
    @PrimaryGeneratedColumn({
        type: 'int',
        comment: 'id',
    })
    id: number

    @ApiProperty({ example: 'text', description: '技术描述' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '技术描述',

    })
    text: string

    @ApiProperty({ example: 'date', description: '创建时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '创建时间',
    })
    createDate: string;

    @ApiProperty({ example: 'updateDate', description: '更新时间' })
    @UpdateDateColumn({
        type: 'datetime',
        comment: '更新时间',
    })
    updateDate: string;

    // 绑定简历主表
    @ApiProperty({ example: 'resumeId', description: '简历ID' })
    @Column({
        type: 'int',
        comment: '简历ID',
    })
    resumeId: number;
    @ManyToOne(() => Resume, (resume) => resume.id)
    @JoinColumn({ name: 'resumeId' })
    resume: Resume;
}